﻿using System;
using System.Collections.Generic;
using System.Linq;
using Prepare.Domain.Entities;

namespace Prepare.Domain
{
    public static class AccountManager
    {
		private static IRepository<Account> Repository
		{
			get { return UnitOfWork.GetRepository<Account>(); }
		}

		private static PrepareEntities Context
		{
			get { return UnitOfWork.GetContext<PrepareEntities>(); }
		}

		public static IEnumerable<Account> GetEmptyNames()
		{
			return Repository.Find(a => String.IsNullOrWhiteSpace(a.FirstName));
		}

		public static object GetTestAccounts()
		{
			return Repository.Find(t => t.UserName.StartsWith("P")).Select( t => new { t.UserName } );
			return from a in Context.Accounts
				   join st in Context.StudentTests on a.AccountId equals st.AccountId
				   orderby a.UserName
				   select new { UserName = a.UserName, TestId = st.TestBlockId, TestDate = st.TestDate };
		}
	}
}
